/**
 * mbaobao.com Inc.
 * Copyright (c) 2011 All Rights Reserved.
 */
package com.peigen.web.depreciate.depreciate.dal.ibatis;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import com.peigen.web.depreciate.depreciate.dal.daointerface.DepreciateUserDAO;


// auto generated imports
import com.peigen.web.depreciate.depreciate.dal.dataobject.DepreciateUserDO;
import org.springframework.dao.DataAccessException;
import java.util.List;
import java.util.Map;
	import java.util.HashMap;
	
/**
 * An ibatis based implementation of dao interface <tt>com.peigen.web.depreciate.depreciate.dal.daointerface.DepreciateUserDAO</tt>.
 *
 * This file is generated by <tt>depreciate-dalgen</tt>, a DAL (Data Access Layer)
 * code generation utility specially developed for <tt>paygw</tt> project.
 * 
 * PLEASE DO NOT MODIFY THIS FILE MANUALLY, or else your modification may
 * be OVERWRITTEN by someone else. To modify the file, you should go to 
 * directory <tt>(project-home)/biz/dal/src/conf/dalgen</tt>, and 
 * find the corresponding configuration file (<tt>tables/depreciate_user.xml</tt>). 
 * Modify the configuration file according to your needs, then run <tt>depreciate-dalgen</tt> 
 * to generate this file.
 *
 * @author peigen
 */ 
@SuppressWarnings({ "unchecked", "rawtypes" })

public class IbatisDepreciateUserDAO extends SqlMapClientDaoSupport implements DepreciateUserDAO {
	/**
	 *  Insert one <tt>DepreciateUserDO</tt> object to DB table <tt>depreciate_user</tt>, return primary key
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>insert into depreciate_user(id,user_name,user_passwd,status,user_email,raw_add_time) values (?, ?, ?, ?, ?, ?)</tt>
	 *
	 *	@param depreciateUser
	 *	@return String
	 *	@throws DataAccessException
	 */	 
    public String insert(DepreciateUserDO depreciateUser) throws DataAccessException {
    	if (depreciateUser == null) {
    		throw new IllegalArgumentException("Can't insert a null data object into db.");
    	}
    	
        getSqlMapClientTemplate().insert("MS-DEPRECIATE-USER-INSERT", depreciateUser);

        return depreciateUser.getId();
    }

	/**
	 *  Query DB table <tt>depreciate_user</tt> for records.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>select id, user_name, user_passwd, status, user_email, raw_add_time, raw_update_time from depreciate_user</tt>
	 *
	 *	@return List<DepreciateUserDO>
	 *	@throws DataAccessException
	 */	 
    public List<DepreciateUserDO> loadAll() throws DataAccessException {

        return getSqlMapClientTemplate().queryForList("MS-DEPRECIATE-USER-LOAD-ALL", null);

    }

	/**
	 *  Query DB table <tt>depreciate_user</tt> for records.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>select id, user_name, user_passwd, status, user_email, raw_add_time, raw_update_time from depreciate_user where (id = ?)</tt>
	 *
	 *	@param id
	 *	@return DepreciateUserDO
	 *	@throws DataAccessException
	 */	 
    public DepreciateUserDO findById(String id) throws DataAccessException {

        return (DepreciateUserDO) getSqlMapClientTemplate().queryForObject("MS-DEPRECIATE-USER-FIND-BY-ID", id);

    }

	/**
	 *  Query DB table <tt>depreciate_user</tt> for records.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>select id, user_name, user_passwd, status, user_email, raw_add_time, raw_update_time from depreciate_user where (user_name = ?)</tt>
	 *
	 *	@param userName
	 *	@return DepreciateUserDO
	 *	@throws DataAccessException
	 */	 
    public DepreciateUserDO findByUserName(String userName) throws DataAccessException {

        return (DepreciateUserDO) getSqlMapClientTemplate().queryForObject("MS-DEPRECIATE-USER-FIND-BY-USER-NAME", userName);

    }

	/**
	 *  Query DB table <tt>depreciate_user</tt> for records.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>select id, user_name, user_passwd, status, user_email, raw_add_time, raw_update_time from depreciate_user where (user_email = ?)</tt>
	 *
	 *	@param userEmail
	 *	@return DepreciateUserDO
	 *	@throws DataAccessException
	 */	 
    public DepreciateUserDO findByUserEmail(String userEmail) throws DataAccessException {

        return (DepreciateUserDO) getSqlMapClientTemplate().queryForObject("MS-DEPRECIATE-USER-FIND-BY-USER-EMAIL", userEmail);

    }

	/**
	 *  Query DB table <tt>depreciate_user</tt> for records.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>select id, user_name, user_passwd, status, user_email, raw_add_time, raw_update_time from depreciate_user</tt>
	 *
	 *	@param limitStart
	 *	@param pageSize
	 *	@return List<DepreciateUserDO>
	 *	@throws DataAccessException
	 */	 
    public List<DepreciateUserDO> loadAllPageList(int limitStart, int pageSize) throws DataAccessException {
        Map param = new HashMap();

        param.put("limitStart", new Integer(limitStart));
        param.put("pageSize", new Integer(pageSize));

        return getSqlMapClientTemplate().queryForList("MS-DEPRECIATE-USER-LOAD-ALL-PAGE-LIST", param);

    }

	/**
	 *  Update DB table <tt>depreciate_user</tt>.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>update depreciate_user set user_passwd=?, status=?, user_email=? where (id = ?)</tt>
	 *
	 *	@param userPasswd
	 *	@param status
	 *	@param userEmail
	 *	@param id
	 *	@return int
	 *	@throws DataAccessException
	 */	 
    public int updateForId(String userPasswd, String status, String userEmail, String id) throws DataAccessException {
        Map param = new HashMap();

        param.put("userPasswd", userPasswd);
        param.put("status", status);
        param.put("userEmail", userEmail);
        param.put("id", id);

        return getSqlMapClientTemplate().update("MS-DEPRECIATE-USER-UPDATE-FOR-ID", param);
    }

	/**
	 *  Delete records from DB table <tt>depreciate_user</tt>.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>delete from depreciate_user where (user_name = ?)</tt>
	 *
	 *	@param userName
	 *	@return int
	 *	@throws DataAccessException
	 */	 
    public int deleteByUserNameForTest(String userName) throws DataAccessException {

        return getSqlMapClientTemplate().delete("MS-DEPRECIATE-USER-DELETE-BY-USER-NAME-FOR-TEST", userName);
    }

	/**
	 *  Delete records from DB table <tt>depreciate_user</tt>.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>delete from depreciate_user where (user_email = ?)</tt>
	 *
	 *	@param userEmail
	 *	@return int
	 *	@throws DataAccessException
	 */	 
    public int deleteByUserEmailForTest(String userEmail) throws DataAccessException {

        return getSqlMapClientTemplate().delete("MS-DEPRECIATE-USER-DELETE-BY-USER-EMAIL-FOR-TEST", userEmail);
    }

}